<template>
	<view class="wrap">
		<view class="mian" v-model="item">
			<view class="demo-warter w-50 ">
				<view class="image">
					<image v-if="item.avatar" :src="baseUrl+item.avatar" mode="" class="image"></image>
					<image v-if="!item.avatar" :src="imagedf" mode="" class="image"></image>
				</view>
				<view class="dtile">
					<view class="rit">
						<view class="demo-text">
							用户名称:{{item.userName}}
						</view>
						<view class="demo-text">
							手机号码:{{item.phonenumber}}
						</view>
						<view class="demo-text">
							用户邮箱:{{item.email}}
						</view>
						<view class="demo-text">
							所属部门:{{item.dept.deptName}}
						</view>
						<view class="demo-text">
							所属角色:{{roleGroup}}
						</view>
						<view class="demo-text">
							创建日期:{{item.createTime}}
						</view>
					</view>
				</view>
				<!-- <u-icon name="close-circle-fill" color="#fa3534" size="34" class="u-close" @click="remove(item.id)"></u-icon> -->
			</view>
		</view>
	</view>


</template>

<script>
	import proData from "@/common/projectData.js";
	import imgData from "@/common/uiImg.js";
	import {
		baseUrl
	} from '../../common/utils/request.js'
	import {
		getUserInfo
	} from '../../common/api/info.js'
	import {
		checkNullAndUndefine
	} from '../../common/utils/checkNU.js';
	export default {
		data() {
			return {
				baseUrl: 'https://xcx.includesteven.top',
				item: {},
				imagedf: 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1274304873,2136522871&fm=26&gp=0.jpg',
				queryParams: {},
				roleGroup: {},
				title: 'uploadFile',
				imageSrc: ''
			}
		},
		onUnload() {
			this.imageSrc = '';
		},
		onLoad(option) {
			this.baseUrl = baseUrl;
			this.addRandomData();
			console.log(this.baseUrl);
		},
		methods: {
			addRandomData() {
				getUserInfo().then(response => {
					this.roleGroup = checkNullAndUndefine(this.roleGroup)
					this.roleGroup = response[1].data.roleGroup;
					this.item = response[1].data.data;
					for (let i in this.item) {
						if (i != 'avatar') {
							this.item[i] = checkNullAndUndefine(this.item[i])
						}
					}
				});

			},
			changeImage() {
				uni.chooseImage({
					count: 1,
					success: (res) => {
						const tempFilePaths = res.tempFilePaths;
						uni.uploadFile({
							url: this.baseUrl, //post请求的地址
							filePath: tempFilePaths[0],
							name: 'avatar',
							formData: {
								'username': this.userInfo.username //formData是指除了图片以外，额外加的字段
							},
							success: (uploadFileRes) => {
								//这里要注意，uploadFileRes.data是个String类型，要转对象的话需要JSON.parse一下
								var obj = JSON.parse(uploadFileRes.data);

							}
						})
					},
				});
			},
		}
	}
</script>

<style>
	/* page不能写带scope的style标签中，否则无效 */
	page {
		background-color: rgb(240, 240, 240);
	}
</style>

<style lang="scss" scoped>
	.demo-image {
		width: 100%;
		border-radius: 4px;
	}

	.demo-title {
		font-size: 45rpx;
		margin-top: 5px;
		color: $u-main-color;
	}

	.demo-tag {
		display: flex;
		margin-top: 5px;
	}

	.demo-tag-owner {
		background-color: $u-type-success;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}

	.demo-tag-text {
		border: 1px solid $u-type-success;
		color: $u-type-success;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}

	.demo-text-sm {
		margin: 10px;
		line-height: 2;
	}

	.demo-text {
		margin: 10px;
		line-height: 2;
		font-weight: 700;
	}

	.demo-shop {
		font-size: 22rpx;
		color: $u-tips-color;
		margin-top: 5px;
	}

	.mian {
		width: 257%;
	}

	.w-50 {
		width: 38%;
	}

	.demo-warter {
		border-radius: 8px;
		margin: 10px 5px;
		background-color: #ffffff;
		padding: 8px;
		// display: flex;
	}

	.dtile {
		display: flex;
		flex-wrap: wrap;
	}

	.rit {
		margin-left: 5px;
	}

	.foot {
		margin-left: 5px;
	}

	.image {
		margin-left: 20%;
		//margin-top: 60rpx;
		height: 300rpx;
		width: 300rpx;
		border-radius: 50%;

	}
</style>
